package cn.iocoder.yudao.module.pay.api.order;

import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderRespDTO;
import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
import cn.iocoder.yudao.module.pay.service.walletwithdraw.PayWalletWithdrawService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 支付单 API 实现类
 *
 * @author 芋道源码
 */
@Service
public class PayOrderApiImpl implements PayOrderApi {

    @Resource
    private PayOrderService payOrderService;
    @Resource
    private PayWalletWithdrawService payWalletWithdrawService;

    @Override
    public Long createOrder(PayOrderCreateReqDTO reqDTO) {
        return payOrderService.createOrder(reqDTO);
    }

    @Override
    public PayOrderRespDTO getOrder(Long id) {
        PayOrderDO order = payOrderService.getOrder(id);
        return PayOrderConvert.INSTANCE.convert2(order);
    }

    @Override
    public void updatePayOrderPrice(Long id, Integer payPrice) {
        payOrderService.updatePayOrderPrice(id, payPrice);
    }

    @Override
    public void refundDeposit(Long payOrderId, Long userId) {
        payOrderService.refundDeposit(payOrderId, userId);
    }

    @Override
    public void createWithDrawBySystem(BigDecimal price, Long userId, String orderNo, String name, String bankId, String bankName, String bankAddress) {
        payWalletWithdrawService.createWithDrawBySystem(price,userId,orderNo,name, bankId, bankName, bankAddress);
    }

    @Override
    public void rollbackPayExpire(Long payOrderId) {
        payOrderService.rollbackPayExpire(payOrderId);
    }


}
